package com.xz.coursearrange.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xz.coursearrange.entity.CoursePlan;
import com.xz.coursearrange.entity.request.UpdateCourseRequest;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 */
public interface CoursePlanDao extends BaseMapper<CoursePlan> {
    //修改课表
    int updateCourseTime(UpdateCourseRequest request);
    //查询教室对应时间段是否空闲
    String selectionCLassRoomTimeNull(@Param("classRoom") String classRoom,@Param("lessonPlan") String lessonPlan);
    //查询年级教室
    List<String> selectionClassRoomGrade(@Param("grade") String grade);
    //查询教师空闲时间
    List<String> selectTeacherTime(@Param("id") Integer id);
    //查询班级空闲时间
    List<String> selectClassTime(@Param("id") Integer id);
    // 插入课程计划
    @Insert("insert into tb_course_plan(grade_no, class_no, course_no, teacher_no, classroom_no, class_time, semester) values(#{grade_no}, #{class_no}, #{course_no}, #{teacher_no}, #{classroom_no}, #{class_time}, #{semester})")
    void insertCoursePlan(@Param("grade_no") String grade_no, @Param("class_no") String class_no, @Param("course_no") String course_no,
                          @Param("teacher_no") String teacher_no, @Param("classroom_no") String classroom_no, @Param("class_time") String class_time, @Param("semester") String semester);

    @Update("truncate tb_course_plan")
    void deleteAllPlan();

    @Insert({
            "<script>",
            "insert into tb_course_plan(grade_no, class_no, course_no, teacher_no, classroom_no, class_time, semester) values",
            "<foreach collection='list' item='item' index='index' separator=','>",
            "(#{item.gradeNo}, #{item.classNo}, #{item.courseNo}, #{item.teacherNo}, #{item.classroomNo}, #{item.classTime}, #{semester})",
            "</foreach>",
            "</script>"
    })
    void insertCoursePlanBatch(@Param("list") List<CoursePlan> coursePlanList, @Param("semester") String semester);
//    @Override
//    Integer insertBatchSomeColumn(Collection<CoursePlan> list);
}
